<template>
	<view class="login">
		<view class="bg">
			<image src="../../static/login.jpg"></image>
		</view>
		<view class="content">
			<view class="message">
				<view class="detail">
					<input type="text" placeholder="邮箱登录" v-model="login_admin">
				</view>
				<view class="detail">
					<input type="safe-password" password="true" placeholder="请输入密码" v-model="login_pass">
				</view>
			</view>
			<view class="message2">
				<text class="tip">忘记密码？</text>
				<text class="tip" @click="register">注册账号</text>
			</view>
			<view class="message3">
				<button class="button" @click="login">登录</button>
			</view>
		</view>
	</view>
	
</template>

<script>
import http from '../../utils/http'
	export default {
		data() {
			return {
				login_admin:'',
				login_pass:'',
				// adminId:'',
				adminName:'',
			}
		},
		methods: {
			login(){
				http({
					method:'post',
					url:`/admin/login`,
					data:{
						adminEmail:this.login_admin,
						adminPWD:this.login_pass
					},
					success: (res) => {
						// console.log(res.data.data)
						if(res.data.code == 1){
							uni.showToast({titile:'登录成功',icon:'success'})
							// console.log(res.data.data.adminName)
							uni.setStorageSync('adminName', res.data.data.adminName);
							uni.navigateTo({
								url: '../backend/mainPage'
							});
						}else
						{
							uni.showToast({titile:'登录失败',icon:'error'})
						}	
					},
					fail:(error)=>{
						// console.log(error)
						uni.showToast({titile:'出错了'.msg,icon:'error'})
					}
				})
			},
			register(){
				uni.navigateTo({
					url: '../backend/register'
				});
			}
		}
	}
</script>

<style>
.login {
	position: relative;
	display: flex;
}
.bg image {
	position: absolute;
	height: 1280rpx;
	width: 750rpx;
}
.nav{
	display: flex;
	color: aqua;
	position: absolute;
	margin-top: 30rpx;
	font-family: YouYuan;
}
.content {
	margin-left: 80rpx;
	margin-top: 180rpx;
	position: absolute;
	text-align: center;
}
.message{
	margin-top: 20%;
	color: aqua;
}
.message2{
	display: flex;
	justify-content: space-around; 
	align-items: flex-start;
}
.message3{
	margin-top: 10%;
}
.detail input{
	color: aqua;
	margin-left:40rpx ;
	font-size: 32rpx;
	width: 400rpx;
}
.tip{
	color: aqua;
	text-decoration: underline;
	margin-top: 20%;
	font-size: 30rpx;
}
.detail{
	display: flex;
	height: 100rpx;
	align-items: center;
	border-bottom: 1px solid rgba(238, 238, 238, 1);
	margin-left: 30rpx;
	padding-right: 30rpx;
}
.button{
	margin-top: 15rpx;
	text-align: center;
	line-height: 86rpx;
	width: 600rpx;
	height: 86rpx;
	border-radius: 30px;
	background-color: #41c20c;
	color: white;
	font-size: 14px;
}
</style>
